var Tree=function(jsonStr,applyTo){
	var treeJson = eval("("+jsonStr+")");
	var $apply = $("#"+applyTo);
	function roundTree(nodes,$parent,level){
		var $ul = $('<ul></ul>');
		for(var i=0;i<nodes.length;i++){
			var node = nodes[i];
			var leaf = node.childs?false:true;
			var $treenode = TreeNode(leaf,node.isExpend,node.id,node.text,level);
			if(!leaf){
				roundTree(node.childs,$treenode,level+1);
			}
			$ul.append($treenode);
			if($parent) $parent.append($ul);
		}
	}
	roundTree(treeJson,$apply,0);
	
}

function TreeNode(leaf,isExpend,id,text,level){
	var leafStr = leaf?"leaf":isExpend?"btn open":"btn close";
	return $('<li><div style="width:'+level*15+'px"></div><div class="'+leafStr+'"></div><span id="'+id+'">'+text+'</span></li>');
}
